<template>
	<view class="community">
		<view class="head_bg" style="position: relative;"></view>
		<view class="big_box" style="top: -200rpx;">
			<view class="count_tab">
				<view :class="{count_tab_inner1: istrue == true,is_active: tabIndex == 1}" @tap="tabSelect" :data-id="1" style="margin-left: 67rpx;">全部</view>
				<view :class="{count_tab_inner1: istrue == true,is_active: tabIndex == 2}" @tap="tabSelect" :data-id="2" >未处理</view>
				<view :class="{count_tab_inner1: istrue == true,is_active: tabIndex == 3}" @tap="tabSelect" :data-id="3" style="margin-right: 60rpx;">已处理</view>
			</view>
			<view v-if="tabIndex == 1">
				<view v-if="list.length>0" v-for="(info,index) in list" :key="index" class="equ_list"  @tap="toFaltDetail(info._id)">
					<view class="ele_title" style="padding-top: 30rpx;">
						<view class="ele_title_left">
							<view class="ele_title_inner">{{info.residential_quarters_name}}</view>
							<view class="ele_address">
								<image class="ele_address_img" src="../../../common/img/dizhi_hui.png" mode=""></image>
								<text>{{info.residential_quarters_address}}</text>
							</view>
						</view>
						<view v-if="info.processing_status==0" class="falt_status">未处理</view>
						<view v-if="info.processing_status==1" class="falt_status">已处理</view>
					</view>
					<view class="equ_list_inner">
						<view class="equ_list_inner_text">上报人：{{info.user_phone_number}}</view>
						<view class="equ_list_inner_text">终端编号：07 左</view>
						<view class="equ_list_inner_text">故障类型：
						 <text v-if="info.fault_type==0" style="color: #EC692F;">二维码损坏</text>
						 <text v-if="info.fault_type==1" style="color: #EC692F;">插座损坏</text>
						 <text v-if="info.fault_type==2" style="color: #EC692F;">插座没电</text>
						 <text v-if="info.fault_type==3" style="color: #EC692F;">其他</text>
						</view>
						<view class="equ_list_inner_text">上报时间：{{info.failure_time}}</view>
					</view>
					<view class="margin-left-sm margin-right-sm">
						<image :src="info.image_path" style="width:100%;height:200rpx;"></image>
					</view>
					<view class="text-orange margin-left-sm">问题描述：{{info.cause_of_failure}}</view>
				</view>
				<view style="height:100rpx;"></view>
				<view v-if="list.length==0" class="margin-top-lg text-center">
					<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
				</view>
				<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
					{{loadingTxt}} 共({{list.length}}条记录)
				</view>
			</view>
			<view v-if="tabIndex == 2">
				<view v-if="list.length>0" v-for="(info,index) in list" :key="index" class="equ_list"  @tap="toFaltDetail(info._id)">
					<view class="ele_title" style="padding-top: 30rpx;">
						<view class="ele_title_left">
							<view class="ele_title_inner">{{info.residential_quarters_name}}</view>
							<view class="ele_address">
								<image class="ele_address_img" src="../../../common/img/dizhi_hui.png" mode=""></image>
								<text>{{info.residential_quarters_address}}</text>
							</view>
						</view>
						<view v-if="info.processing_status==0" class="falt_status">未处理</view>
						<view v-if="info.processing_status==1" class="falt_status">已处理</view>
					</view>
					<view class="equ_list_inner">
						<view class="equ_list_inner_text">上报人：{{info.user_phone_number}}</view>
						<view class="equ_list_inner_text">终端编号：07 左</view>
						<view class="equ_list_inner_text">故障类型：
						 <text v-if="info.fault_type==0" style="color: #EC692F;">二维码损坏</text>
						 <text v-if="info.fault_type==1" style="color: #EC692F;">插座损坏</text>
						 <text v-if="info.fault_type==2" style="color: #EC692F;">插座没电</text>
						 <text v-if="info.fault_type==3" style="color: #EC692F;">其他</text>
						</view>
						<view class="equ_list_inner_text">上报时间：{{info.failure_time}}</view>
					</view>
					<view class="margin-left-sm margin-right-sm">
						<image :src="info.image_path" style="width:100%;height:200rpx;"></image>
					</view>
					<view class="text-orange margin-left-sm">问题描述：{{info.cause_of_failure}}</view>
				</view>
				<view style="height:100rpx;"></view>
				<view v-if="list.length==0" class="margin-top-lg text-center">
					<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
				</view>
				<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
					{{loadingTxt}} 共({{list.length}}条记录)
				</view>
			</view>
			<view v-if="tabIndex == 3">
				<view v-if="list.length>0" v-for="(info,index) in list" :key="index" class="equ_list"  @tap="toFaltDetail(info._id)">
					<view class="ele_title" style="padding-top: 30rpx;">
						<view class="ele_title_left">
							<view class="ele_title_inner">{{info.residential_quarters_name}}</view>
							<view class="ele_address">
								<image class="ele_address_img" src="../../../common/img/dizhi_hui.png" mode=""></image>
								<text>{{info.residential_quarters_address}}</text>
							</view>
						</view>
						<view v-if="info.processing_status==0" class="falt_status">未处理</view>
						<view v-if="info.processing_status==1" class="falt_status">已处理</view>
					</view>
					<view class="equ_list_inner">
						<view class="equ_list_inner_text">上报人：{{info.user_phone_number}}</view>
						<view class="equ_list_inner_text">终端编号：07 左</view>
						<view class="equ_list_inner_text">故障类型：
						 <text v-if="info.fault_type==0" style="color: #EC692F;">二维码损坏</text>
						 <text v-if="info.fault_type==1" style="color: #EC692F;">插座损坏</text>
						 <text v-if="info.fault_type==2" style="color: #EC692F;">插座没电</text>
						 <text v-if="info.fault_type==3" style="color: #EC692F;">其他</text>
						</view>
						<view class="equ_list_inner_text">上报时间：{{info.failure_time}}</view>
					</view>
					<view class="margin-left-sm margin-right-sm">
						<image :src="info.image_path" style="width:100%;height:200rpx;"></image>
					</view>
					<view class="text-orange margin-left-sm">问题描述：{{info.cause_of_failure}}</view>
				</view>
				<view style="height:100rpx;"></view>
				<view v-if="list.length==0" class="margin-top-lg text-center">
					<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
				</view>
				<view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
					{{loadingTxt}} 共({{list.length}}条记录)
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				loadingTxt:'加载更多',
				tabIndex: 1,
				istrue:true,
				list:[],//全部订单
			}
		},
		onShow() {
			page=1;
			this.getalllist();
		},
		methods: {
			tabSelect(e) {
				page=1;
				this.tabIndex = e.currentTarget.dataset.id;
				this.list=[];
				this.loadingTxt='加载更多',
				this.getalllist();
			},
			getalllist(){
				let that=this;
				let type;
				if(this.tabIndex==1){
					type="0";
				}else if(this.tabIndex==2){
					type="1";
				}else if(this.tabIndex==3){
					type="2";
				}
				that.http.tokenreq({
					url: "fault/v1/page",
					data:{
						'pageindex':page,
						"type":type
					}
				}).then((res) => {
					let e=res.data;
					console.log(e)
					if(e.code==0 && e.success){
						that.list=e.rows;
						page++
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				let type;
				if(this.tabIndex==1){
					type="0";
				}else if(this.tabIndex==2){
					type="1";
				}else if(this.tabIndex==3){
					type="2";
				}
				that.http.tokenreq({
					url: "fault/v1/page",
					data:{
						'pageindex':page,
						"type":type
					}
				}).then((res) => {
					uni.hideLoading();
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			},
			toFaltDetail(id){
				uni.navigateTo({
					url: '/pages/breakdown/falt_detail/falt_detail?id='+id
				})
			},
		}
	}
</script>
